<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <link rel="stylesheet" href="styles/style.css">
        <link rel="stylesheet" href="styles/theme/atom-one-dark.css">
        <title>例子10-ES6/7常用语法介绍</title>
    </head>
    <body>
        <pre>
            <code>
                // 例子10

                let {bar, foo, baz} = {foo: 'a', bar: 'b'};
                console.log(bar, foo, baz); // "b" "a" undefined

                //--------------------------------------------------------------------------

                let {foo: baz} = {foo: 'a', bar: 'b'};
                console.log(baz); // "a"

                let obj = {first: 'hello', last: 'world'};
                let {first: f, last: g} = obj;
                console.log(f, g); // "hello" "world"

                //--------------------------------------------------------------------------

                let obj = {
                    p: [
                        'hello',
                        {y: 'world'}
                    ]
                };
                let {p, p:[x, {y}]} = obj;
                console.log(p, x, y); // ["hello", {y: "world"}] "hello" "world"

                //--------------------------------------------------------------------------

                const node = {
                    loc: {
                        start: {
                            line: 1,
                            column: 5
                        }
                    }
                };
                let { loc, loc: { start }, loc: { start: { line }} } = node;
                console.log(line, loc, start); //1 {start: {line:1, column}} {line:1, column:5}
            </code>
        </pre>
        <script src="scripts/libs/highlight.pack.js"></script>
        <script src="scripts/10.js"></script>
        <script>
            hljs.initHighlightingOnLoad();
        </script>
    </body>
</html>